home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb-4.5 / sun4.md / include / link.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-24  |  5.1 KB  |  158 lines

  1. /*    @(#)link.h 1.6 88/08/19 SMI    */
  2.  
  3. /*
  4.  * Copyright (c) 1987 by Sun Microsystems, Inc.
  5.  */
  6.  
  7. /*
  8.  * Link editor public definitions.
  9.  */
  10.  
  11. #ifndef _link_h
  12. #define _link_h
  13.  
  14. /*
  15.  * Structure describing logical name and requirements on an object
  16.  * which is to be loaded dynamically.
  17.  */
  18. struct old_link_object {
  19.     char    *lo_name;        /* name of object */
  20.     int    lo_library : 1,        /* searched for by library rules */
  21.         lo_unused : 31;
  22.     short    lo_major;        /* major version number */
  23.     short    lo_minor;        /* minor version number */
  24. };
  25.  
  26. struct link_object {
  27.     long    lo_name;        /* name (often relative) */
  28.     int    lo_library : 1,        /* searched for by library rules */
  29.         lo_unused : 31;
  30.     short    lo_major;        /* major version number */
  31.     short    lo_minor;        /* minor version number */
  32.     long    lo_next;        /* next one (often relative) */
  33. };
  34.  
  35. /*
  36.  * Structure describing name and placement of dynamically loaded
  37.  * objects in a process' address space.
  38.  */
  39. struct link_map {
  40.     caddr_t    lm_addr;        /* address at which object mapped */
  41.     char     *lm_name;        /* full name of loaded object */
  42.     struct    link_map *lm_next;    /* next object in map */
  43.     struct    link_object *lm_lop;    /* link object that got us here */
  44.     caddr_t lm_lob;            /* base address for said link object */
  45.     int    lm_rwt : 1;        /* text is read/write */
  46.     struct    link_dynamic *lm_ld;    /* dynamic structure */
  47.     caddr_t    lm_lpd;            /* loader private data */
  48. };
  49.  
  50. /*
  51.  * Version 1 of dynamic linking information.  With the exception of
  52.  * ld_loaded (determined at execution time) and ld_stab_hash (a special
  53.  * case of relocation handled at execution time), the values in this
  54.  * structure reflect offsets from the containing link_dynamic structure.
  55.  */
  56. struct link_dynamic_1 {
  57.     struct    link_map *ld_loaded;    /* list of loaded objects */
  58.     long    ld_need;        /* list of needed objects */
  59.     long    ld_rules;        /* search rules for library objects */
  60.     long    ld_got;            /* global offset table */
  61.     long    ld_plt;            /* procedure linkage table */
  62.     long    ld_rel;            /* relocation table */
  63.     long    ld_hash;        /* symbol hash table */
  64.     long    ld_stab;        /* symbol table itself */
  65.     long    (*ld_stab_hash)();    /* "pointer" to symbol hash function */
  66.     long    ld_buckets;        /* number of hash buckets */
  67.     long    ld_symbols;        /* symbol strings */
  68.     long    ld_symb_size;        /* size of symbol strings */
  69.     long    ld_text;        /* size of text area */
  70. };
  71.  
  72. struct link_dynamic_2 {
  73.     struct    link_map *ld_loaded;    /* list of loaded objects */
  74.     long    ld_need;        /* list of needed objects */
  75.     long    ld_rules;        /* search rules for library objects */
  76.     long    ld_got;            /* global offset table */
  77.     long    ld_plt;            /* procedure linkage table */
  78.     long    ld_rel;            /* relocation table */
  79.     long    ld_hash;        /* symbol hash table */
  80.     long    ld_stab;        /* symbol table itself */
  81.     long    (*ld_stab_hash)();    /* "pointer" to symbol hash function */
  82.     long    ld_buckets;        /* number of hash buckets */
  83.     long    ld_symbols;        /* symbol strings */
  84.     long    ld_symb_size;        /* size of symbol strings */
  85.     long    ld_text;        /* size of text area */
  86.     long    ld_plt_sz;        /* size of procedure linkage table */
  87. };
  88.  
  89. /*
  90.  * Structure pointing to run time allocated common symbols and
  91.  * its string.
  92.  */
  93. struct rtc_symb {
  94.     struct    nlist *rtc_sp;        /* symbol for common */
  95.     struct    rtc_symb *rtc_next;    /* next common */
  96. };
  97.  
  98. /*
  99.  * Debugger interface structure.
  100.  */
  101. struct     ld_debug {
  102.     int    ldd_version;        /* version # of interface */
  103.     int    ldd_in_debugger;    /* a debugger is running us */
  104.     int    ldd_sym_loaded;        /* we loaded some symbols */
  105.     char    *ldd_bp_addr;        /* place for ld-generated bpt */
  106.     int    ldd_bp_inst;        /* instruction which was there */
  107.     struct rtc_symb *ldd_cp;    /* commons we built */
  108. };
  109.  
  110. /*
  111.  * Structure associated with each object which may be or which requires
  112.  * execution-time link editing.  Used by the run-time linkage editor to
  113.  * identify needed objects and symbol definitions and references.
  114.  */
  115. struct     old_link_dynamic {
  116.     int    ld_version;        /* version # of this structure */
  117.     union {
  118.         struct link_dynamic_1 ld_1;
  119.     } ld_un;
  120.  
  121.     int    in_debugging;
  122.     int    sym_loaded;
  123.     char    *bp_addr;
  124.     int    bp_inst;
  125.     struct rtc_symb *cp;         /* pointer to an array of runtime */
  126.                     /* allocated common symbols. */
  127. };
  128.  
  129. struct    link_dynamic {
  130.     int    ld_version;        /* version # of this structure */
  131.     struct     ld_debug *ldd;
  132.     union {
  133.         struct link_dynamic_1 *ld_1;
  134.         struct link_dynamic_2 *ld_2;
  135.     } ld_un;
  136. };
  137.  
  138. #define v2 ld_un.ld_2
  139. #define v1 ld_un.ld_1
  140.  
  141. /*
  142.  * get size of relocations
  143.  */
  144. #define GETGOTSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_plt - ((struct old_link_dynamic *) x)->v1.ld_got : (x)->v2->ld_plt - (x)->v2->ld_got)
  145.  
  146. #define GETPLTSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_rel - ((struct old_link_dynamic *) x)->v1.ld_plt : (x)->v2->ld_rel - (x)->v2->ld_plt)
  147.  
  148. #define GETRELSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_hash - ((struct old_link_dynamic *) x)->v1.ld_rel : (x)->v2->ld_hash - (x)->v2->ld_rel)
  149.  
  150. #define GETHASHSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_stab - ((struct old_link_dynamic *) x)->v1.ld_hash : (x)->v2->ld_stab - (x)->v2->ld_hash)
  151.  
  152. #define GETSTABSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_symbols - ((struct old_link_dynamic *) x)->v1.ld_stab : (x)->v2->ld_symbols - (x)->v2->ld_stab)
  153.  
  154. #undef v2
  155. #undef v1
  156.  
  157. #endif /*!_link_h*/
  158.